package com.ks.cms.controller.dto;


import lombok.Data;

import java.util.ArrayList;

/**
 * Created by wanglicheng on 2020/12/21.
 * 数据条件查询的基类(考虑放到Core工程中）
 * 平台上各种数据对像的条件查询不做特别规定时都以此数据结构来接收查询条件.以下为示例：
 {
 "startTime":"",
 "endTime":"",
 "fields":[
 {"name":"fieldname","value":"abc","isFullmatch":false},
 {"name":"fieldname","value":"abc","isFullmatch":false}
 ],
 "states":[
 {"name":"fieldname","value":"abc"},
 {"name":"fieldname","value":"abc"}
 ],
 "orderBy":"",
 "onlyData":true,
 "expand":["","",""],
 "limit":0,
 "pageIndex":0
 }
 */
@Data
public class SearchCriteriaBase {
    public String startTime;
    public String endTime;
    public ArrayList<matchField> fields;
    public ArrayList<StateField> states;
    public String orderBy;
    public boolean isOnlyData;
    public ArrayList<String> expand; //这里列出的每一个字符串表示要查询的数据对象的一个子对像，要求对子对象数据进行展开
    public int limit;
    public int pageIndex;

    @Data
    public static class matchField extends StateField{
        public boolean isFullMatch;
    }
    @Data
    public static class StateField {
        public String name;
        public String value;
    }

    /**
     * 条件查询的返回值基础数据结构
     * @param <T>
     */
    @Data
    public static class SearchResultBase<T>{
        public int count;
        public int limit;
        public int pageIndex;
        public boolean hasMore;
        public ArrayList<T> items;
    }
}


